@extends('layouts.app')

@section('content')
    <div class="container">
        <div class="row justify-content-center">
                    <h3>我的入住记录</h3>

                        @if($bookings->total() === 0)
                            <h1 class="text-info">您没有订单信息</h1>
                        @else
                            <table class="table table-striped table-hover">
                                <tr>
                                    <th scope="col">订单号</th>
                                    <th scope="col">下单日期</th>
                                    <th scope="col">房间类型</th>
                                    <th scope="col">预计入住日期</th>
                                    <th scope="col">预计退房日期</th>
                                    <th scope="col">总计</th>
                                    <th scope="col">已支付</th>
                                    <th scope="col">状态</th>
                                    <th scope="col">操作</th>
                                </tr>
                                @foreach($orders as $order)
                                <tr>
                                    <th scope="row">{{ $order->id }}</th>
                                    <td>{{ $order->created_at }}</td>
                                    <td>{{ $order->availability->room_type->name }}</td>
                                    <td>{{ $order->availability->from }}</td>
                                    <td>{{ $order->availability->to }}</td>
                                    <td>{{ $order->payment->total }}</td>
                                    <td>{{ $order->payment->paid }}</td>
                                    <td>
                                    @if ($order->cancelled == true)
                                        已取消
                                    @elseif($order->check_in == true)
                                        已入住
                                    @else
                                        等待入住
                                    @endif
                                    </td>
                                    <td>
                                    @if ($order->availability->is_valid == true)
                                        <a href="#" role="button" class="btn btn-primary">修改</a>
                                        <a href="#" role="button" class="btn btn-danger">取消</a>
                                    @else
                                        <a href="#" role="button" class="btn btn-danger">删除</a>
                                    @endif
                                    </td>
                                </tr>
                                @endforeach
                            </table>
                            {{ $orders->links() }}
                        @endif
                    </div>
            </div>
@endsection
